<template>
  <form-dialog
    :title="$t('workspace.sharingTenants')"
    :visible="visible"
    width="30%"
    @handleClose="handleClose"
  >
    <template #content>
      <div class="tip-container">
        <el-form ref="form" :model="formData" :rules="formRules" v-loading="loading" label-width="122px">
          <el-form-item :label="$t('workspace.selectTenant')" prop="">
            <el-input v-model="formData.selectTenants"></el-input>
          </el-form-item>
          <el-form-item :label="$t('common.tenants')" prop="">
            <el-select v-model="formData.tenants" :placeholder="$t('workspace.selectSharingTenant')">
              <el-option
                v-for="item in options"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
      </div>
    </template>
    <template #footer>
      <el-button @click="handleClose">{{ $t('common.cancel') }}</el-button>
      <el-button type="primary" @click.native="submit" :loading="loading">{{ $t('common.confirm') }}</el-button>
    </template>
  </form-dialog>
</template>
<script lang="ts">
import Vue from 'vue';
import FormDialog from '../../../components/Dialog/formDialog.vue';
export default Vue.extend({
  components: { FormDialog },
  props: {
    updateMethod: {
      type: Function,
      default() {
        return () => Promise.resolve();
      }
    }
  },
  data() {
    return {
      visible: false,
      loading: false,
      formData: {
        tenants: '',
        selectTenants: ''
      },
      formRules: {

      },
      options: [],
    }
  },
  methods: {
    init(formData: any) {
      this.visible = true;
    },
    handleClose() {
      (this as any).visible = false;
      (this as any).loading = false;
    },
    submit() {
      (this as any).visible = false;
    }
  }
})
</script>
<style lang="scss" scoped>
::v-deep .el-form {
  display: flex;
  flex-direction: column;
  align-items: center;

  .el-form-item.el-form-item--small {
    display: flex;
    justify-content: flex-end !important;
    align-items: center;
    padding-right: 50px;
    width: 88%;
    flex-shrink: 0;
  }
}
</style>
